<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <%@ include file="/pages/common/header.jsp" %>
    <script type="text/javascript">
        $(function () {
            // 切换验证码
            $("#kaptcha").click(function () {
                this.src = "${basePath}KaptchaServlet.jpg?d=" + new Date().getTime(); // ?d=" + new Date().getTime()是为了跳过浏览器缓存，从服务器获取新的验证码
                return false;
            });

            $("#register").click(function () {
                location.href = "pages/user/register.jsp";
                return false;
            });
        });
    </script>
</head>
<body>
<center>
    <div>
        <h3>用户登录</h3>
    </div>
    <div class="error-message">${msg}</div>
    <form action="UserServlet" method="post" id="login-form">
        <input type="hidden" name="action" value="login">
        <table id="login-table">
            <tr>
                <td>用户名：</td>
                <td><input type="text" name="username" value="${username}"></td>
            </tr>
            <tr>
                <td>密码：</td>
                <td><input type="password" name="password" value="${password}"></td>
            </tr>
            <tr>
                <td>验证码：</td>
                <td>
                    <input type="text" name="kaptcha" id="kaptcha-text" style="width: 40%;">
                    <img id="kaptcha" src="KaptchaServlet.jpg" alt="" style="height: 26px;width: 60px;">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="submit" value="登录">
                    <input type="button" value="注册" id="register">
                </td>
            </tr>
        </table>
    </form>
</center>
</body>
</html>